// pages/tuidan/tuidan.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    msg: ['对不起，突然间就不想喝了', "没有钱了", "需要重新下单", "太晚了，我想退单", "无法到场取货"],
    siez: {
      maxHeight: 770,
      minHeight: 550
    },
    currenIndex:-1,
    orderInfo: {
      orderid: "",
      status: "",
      message: "我要申请退单",
    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    const {
      orderid,
      status
    } = options
    const orderInfo = this.data.orderInfo;
    orderInfo.orderid = orderid;
    orderInfo.status = status
    this.setData({
      orderInfo
    })
  },
  getMsg(e) {
    const {
      msg,
      index
    } = e.currentTarget.dataset
    const orderInfo = this.data.orderInfo
    orderInfo.message = msg
    this.setData({
      orderInfo,
      currenIndex:index
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  sumbitData(){
    const {status,orderid,message} = this.data.orderInfo
    console.log('ajax',status,orderid,message);
    new Promise((resolve)=>{
      wx.request({
        url: `http://localhost:5555/shop/orderStatusChange2?orderid=${orderid}&status=${status}&msg=${message}`,
        method:"get",
        success(res){
          resolve(res)
        }
      })
    }).then((res)=>{
      wx.showToast({
        title: '您已申请退单！',
        icon: 'success',
        duration: 2500 //持续的时间
      })
      setTimeout(()=>{
        wx.switchTab({
          url: "/pages/shopCar/shopCar"
        })
      },400)
    })

  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  }
})